//#include "Bullet.h"
//
//// Initialize the Virus instance
//Bullet* Bullet::m_BulletInstance = 0;
//
//Bullet::Bullet(void)
//{
//}
//
//Bullet::~Bullet(void)
//{
//}
//
//Bullet* Bullet::GetInstance(void)
//{
//	// Create the instance if it doesn't exist
//	if(!m_BulletInstance)
//		m_BulletInstance = new Bullet;
//
//	// Return the singleton
//	return m_BulletInstance;
//}
//
//void Bullet::DeleteBulletInstance(void)
//{
//	// Delete all the bullets in the list
//	Bullet::ShutdownBullet();
//	// If instance exist, delete it!
//	if(m_BulletInstance)
//	{
//		delete m_BulletInstance;
//		m_BulletInstance = NULL;
//	}
//}
//
//void Bullet::InitBullet(IDirect3DDevice9* m_pD3DDevice)
//{
//	// Get the device
//	m_Device = m_pD3DDevice;
//
//	////////////////////////////////////////////////////////////////////////////////
//	// X file that is used for all viruses
//	// Start .x loading
//	LPD3DXBUFFER p_D3DXMtrlBuffer;
//	m_dwNumMaterials = 0;
//
//	// Load .x file
//	D3DXLoadMeshFromX( "Models\\Bullet.X", D3DXMESH_SYSTEMMEM,
//		m_Device, NULL, &p_D3DXMtrlBuffer, NULL, &m_dwNumMaterials,
//		&m_pMesh);
//
//	D3DXMATERIAL* d3dxMaterials =
//		(D3DXMATERIAL*)p_D3DXMtrlBuffer->GetBufferPointer();
//
//	// Create an array based on the amount of materials we have
//	m_pMaterials = new D3DMATERIAL9[m_dwNumMaterials];
//	m_pMeshTextures = new LPDIRECT3DTEXTURE9[m_dwNumMaterials];
//
//	// Load each material
//	for( DWORD i = 0; i < m_dwNumMaterials; i++)
//	{
//		m_pMaterials[i] = d3dxMaterials[i].MatD3D;
//
//		m_pMaterials[i].Ambient = m_pMaterials[i].Diffuse;
//
//		m_pMeshTextures[i] = NULL;
//		if( d3dxMaterials[i].pTextureFilename)
//			D3DXCreateTextureFromFile( m_Device,
//			d3dxMaterials[i].pTextureFilename,
//			&m_pMeshTextures[i]);
//	}
//	// End .x loading
//	////////////////////////////////////////////////////////////////////////////////
//
//	// Get the instance of the model manager
//	m_ModelMan = ModelManager::GetInstance();
//	// Get the instance of the Virus enemies
//	m_pVirusEn = VirusEnemy::GetInstance();
//
//	// Set speed variable
//	fSpeed = 2.0f;
//
//	// Initalize killed virus bool
//	bKilledV = false;
//
//	// Initalize the bullet count
//	sBulletCount = 0;
//}
//
//void Bullet::CreateBullet(float fXTarget, float fYTarget, float fZTarget)
//{
//	// Create new bullet structure
//	s_Bullet* currentBullet = new s_Bullet;
//
//	// Set the bullet to alive and set its timer
//	currentBullet->bAlive = true;
//	currentBullet->iTimer = 0;
//	currentBullet->lStartTime = (LONG)timeGetTime();
//
//	// Spawn Bullet on player
//	currentBullet->vecPos.x = m_ModelMan->modelList[0]->vecPos.x;
//	currentBullet->vecPos.y = m_ModelMan->modelList[0]->vecPos.y;
//	currentBullet->vecPos.z = m_ModelMan->modelList[0]->vecPos.z;
//
//	// Get the target spot to travel to
//	currentBullet->vecTarget.x = fXTarget;
//	currentBullet->vecTarget.y = fYTarget;
//	currentBullet->vecTarget.z = fZTarget;
//
//	// Calculate the distant to the target spot
//	vecDistance.x = currentBullet->vecTarget.x - currentBullet->vecPos.x;
//	vecDistance.y = 0.0f;
//	vecDistance.z = currentBullet->vecTarget.z - currentBullet->vecPos.z;
//	/////////////////////////////////////////////////////////////////////////////////////
//	// Calculate and create the bounding boxes
//	// NORMAL BOUNDING "BOX"
//	HRESULT hr = 0;
//	BYTE* pVertices = 0;
//	if( SUCCEEDED(m_pMesh->LockVertexBuffer(0, (void**)&pVertices)))
//	{
//		// Locking the vertex buffer so we can compute the bounds
//		hr = D3DXComputeBoundingBox((D3DXVECTOR3*)pVertices, m_pMesh->GetNumVertices(),
//			D3DXGetFVFVertexSize(m_pMesh->GetFVF()), &currentBullet->vecBBMin, 
//			&currentBullet->vecBBMax);
//
//		// Unlock the vertex buffer
//		m_pMesh->UnlockVertexBuffer();
//
//		// with the min and max vectors we can get the 8 corners for the bounding box
//		currentBullet->vecModelBounds[0] = D3DXVECTOR3(currentBullet->vecBBMin.x, currentBullet->vecBBMin.y, 
//			currentBullet->vecBBMin.z);
//		currentBullet->vecModelBounds[1] = D3DXVECTOR3(currentBullet->vecBBMax.x, currentBullet->vecBBMin.y, 
//			currentBullet->vecBBMin.z);
//		currentBullet->vecModelBounds[2] = D3DXVECTOR3(currentBullet->vecBBMin.x, currentBullet->vecBBMax.y, 
//			currentBullet->vecBBMin.z);
//		currentBullet->vecModelBounds[3] = D3DXVECTOR3(currentBullet->vecBBMax.x, currentBullet->vecBBMax.y, 
//			currentBullet->vecBBMin.z);
//		currentBullet->vecModelBounds[4] = D3DXVECTOR3(currentBullet->vecBBMin.x, currentBullet->vecBBMin.y, 
//			currentBullet->vecBBMax.z);
//		currentBullet->vecModelBounds[5] = D3DXVECTOR3(currentBullet->vecBBMax.x, currentBullet->vecBBMin.y, 
//			currentBullet->vecBBMax.z);
//		currentBullet->vecModelBounds[6] = D3DXVECTOR3(currentBullet->vecBBMin.x, currentBullet->vecBBMax.y, 
//			currentBullet->vecBBMax.z);
//		currentBullet->vecModelBounds[7] = D3DXVECTOR3(currentBullet->vecBBMax.x, currentBullet->vecBBMax.y, 
//			currentBullet->vecBBMax.z);
//	}
//	/////////////////////////////////////////////////////////////////////////////////////
//	// Add the currently loaded bullet to the list
//	bulletList.push_back(currentBullet);
//
//	// Make sure to increment the list by 
//	// adding the newly made bullet
//	sBulletCount++;
//}
//
//void Bullet::UpdateBullet(float fDeltaTime)
//{
//	// If the virus is not killed keep it false/set it from true back to false.
//	bKilledV = false;
//
//	// Step through the bulletList and update
//	for(short i = 0; i < sBulletCount; i++)
//	{
//		if(bulletList[i]->bAlive)
//		{
//			// If the bullet is alive calculate the distance * speed * delta time 
//			bulletList[i]->vecPos.x += vecDistance.x * fSpeed * fDeltaTime;
//			bulletList[i]->vecPos.y += vecDistance.y * fSpeed * fDeltaTime;
//			bulletList[i]->vecPos.z += vecDistance.z * fSpeed * fDeltaTime;
//
//			// Start the timer to keep the bullets from staying alive to long
//			// After 2 seconds kill the bullet by making bAlive false 
//			bulletList[i]->lCurrentTime = (long)timeGetTime();
//			bulletList[i]->lCurrentTime -= bulletList[i]->lStartTime;
//			if(bulletList[i]->lCurrentTime > 1000)
//			{
//				bulletList[i]->iTimer++;
//				if(bulletList[i]->iTimer == 1)
//					bulletList[i]->bAlive = false;
//				bulletList[i]->lStartTime = (LONG)timeGetTime();
//			}
//			// Check collision with viruses
//			if(VirusCollisionDetection(i))
//			{
//				bulletList[i]->bAlive = false;
//				bKilledV = true;
//			}
//		}
//	}
//}
//
//void Bullet::RenderBullet(void)
//{
//	// Draw the Bullet when the player shoots.
//	for(int i = 0; i < sBulletCount; i++)
//	{
//		if(bulletList[i]->bAlive)
//		{
//			// Reset the matrices
//			D3DXMatrixIdentity(&bulletList[i]->scaleMat);
//			D3DXMatrixIdentity(&bulletList[i]->rotMat);
//			D3DXMatrixIdentity(&bulletList[i]->transMat);
//			D3DXMatrixIdentity(&bulletList[i]->worldMat);
//
//			// Rotate, scale, and translate
//			D3DXMatrixScaling(&bulletList[i]->scaleMat, 1.0f, 1.0f, 1.0f);
//			D3DXMatrixRotationYawPitchRoll(&bulletList[i]->rotMat, 0.0f, 0.0f, 0.0f);
//			D3DXMatrixTranslation(&bulletList[i]->transMat, bulletList[i]->vecPos.x, bulletList[i]->vecPos.y, bulletList[i]->vecPos.z);
//
//			// Scale & rotation * translation
//			D3DXMatrixMultiply(&bulletList[i]->scaleMat, &bulletList[i]->rotMat, &bulletList[i]->scaleMat);
//			D3DXMatrixMultiply(&bulletList[i]->worldMat, &bulletList[i]->scaleMat, &bulletList[i]->transMat);
//
//			// Set the transform
//			m_Device->SetTransform(D3DTS_WORLD, &bulletList[i]->worldMat);
//			// Start .x drawing
//			for( DWORD j = 0; j < m_dwNumMaterials; j++)
//			{
//				m_Device->SetMaterial( &m_pMaterials[j]);
//				m_Device->SetTexture( 0, m_pMeshTextures[j]);
//
//				m_pMesh->DrawSubset(j);
//			}
//
//			m_Device->SetTexture(0, NULL);
//
//			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//			//		Testing code!!!!      Drawing Bounding Box to ensure it is correcly placed on model
//			//// Turning on Wireframe
//			//m_Device->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );
//
//			//// get attributes to draw bounding box
//			//float width, height, depth;
//			//width = (bulletList[i]->vecBBMax.x) - (bulletList[i]->vecBBMin.x);
//			//height = (bulletList[i]->vecBBMax.y) - (bulletList[i]->vecBBMin.y);
//			//depth = (bulletList[i]->vecBBMax.z) - (bulletList[i]->vecBBMin.z);
//
//			//// Make a mesh
//			//D3DXCreateBox( m_Device, width, height, depth, &m_BBMesh, NULL);
//			//// Draw box
//			//m_BBMesh->DrawSubset(0);
//
//			//// Turn off WireFrame
//			//m_Device->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
//			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//		}
//	}
//}
//
//void Bullet::CalculateWorldBB(short sBulletID)
//{
//	// Calculates the Bullets bounding box
//	// Convert Object's model space bounding box to world space
//	// Transform the 8 corners of our object space bounding box into world space
//	D3DXVECTOR3 worldBounds[8];
//	for( int i = 0; i < 8; i++)
//		D3DXVec3TransformCoord( &worldBounds[i], &bulletList[sBulletID]->vecModelBounds[i], &bulletList[sBulletID]->worldMat );
//
//	// Pick a corner and set the smallest point and largest point to that corner
//	bulletList[sBulletID]->worldBBmin = worldBounds[0];
//	bulletList[sBulletID]->worldBBmax = worldBounds[0];
//
//	// Find the new minimum and maximum points after transformation
//	// Now, compare the other corners and see if they are smaller or larger
//	for( short i = 1; i < 8; i++ )
//	{
//		if(worldBounds[i].x < bulletList[sBulletID]->worldBBmin.x)
//			bulletList[sBulletID]->worldBBmin.x = worldBounds[i].x;
//		if(worldBounds[i].x > bulletList[sBulletID]->worldBBmax.x)
//			bulletList[sBulletID]->worldBBmax.x = worldBounds[i].x;
//		if(worldBounds[i].y < bulletList[sBulletID]->worldBBmin.y)
//			bulletList[sBulletID]->worldBBmin.y = worldBounds[i].y;
//		if(worldBounds[i].y > bulletList[sBulletID]->worldBBmax.y)
//			bulletList[sBulletID]->worldBBmax.y = worldBounds[i].y;
//		if(worldBounds[i].z < bulletList[sBulletID]->worldBBmin.z)
//			bulletList[sBulletID]->worldBBmin.z = worldBounds[i].z;
//		if(worldBounds[i].z > bulletList[sBulletID]->worldBBmax.z)
//			bulletList[sBulletID]->worldBBmax.z = worldBounds[i].z;	
//	}
//}
//
//bool Bullet::VirusCollisionDetection(short sBulletID)
//{
//	if(bulletList[sBulletID]->bAlive)
//	{
//		// Search through the list of viruses to see if any are being hit
//		for(int i = 0; i < m_pVirusEn->sVirusCount; i++)
//		{
//			// Calculate the world space bounding box for Virus object
//			m_pVirusEn->CalculateWorldBB(i);
//
//			// Calculate the world space bounding box for Bullet object
//			CalculateWorldBB(sBulletID);
//
//			// Collision check on the boundaries
//			if(m_pVirusEn->virusEnList[i]->worldBBmax.x < bulletList[sBulletID]->worldBBmin.x)
//				return false;
//			if(m_pVirusEn->virusEnList[i]->worldBBmax.y < bulletList[sBulletID]->worldBBmin.y)
//				return false;
//			if(m_pVirusEn->virusEnList[i]->worldBBmax.z < bulletList[sBulletID]->worldBBmin.z)
//				return false;
//			if(m_pVirusEn->virusEnList[i]->worldBBmin.x > bulletList[sBulletID]->worldBBmax.x)
//				return false;
//			if(m_pVirusEn->virusEnList[i]->worldBBmin.y > bulletList[sBulletID]->worldBBmax.y)
//				return false;
//			if(m_pVirusEn->virusEnList[i]->worldBBmin.z > bulletList[sBulletID]->worldBBmax.z)
//				return false;
//
//			m_pVirusEn->virusEnList[i]->bAlive = false;
//			// Collision occured
//			return true;
//		}
//		// No virus is alive
//		return false;
//	}
//	// No collision occured
//	return false;
//}
//
//bool Bullet::VirusKilled()
//{
//	return bKilledV;
//}
//
//void Bullet::ShutdownBullet(void)
//{
//	// Delete the power up list
//	for(short i = 0; i < sBulletCount; i++)
//	{
//		delete bulletList[i];
//		bulletList[i] = NULL;
//	}
//
//	// Reset the power up count to 0
//	sBulletCount = 0;
//
//	/////////////////////////////////////////////////////////////////////////////
//	// .X file deleting
//	if(m_pMaterials != NULL)
//	{
//		delete m_pMaterials;
//	}
//
//	if(m_pMeshTextures)
//	{
//		for(DWORD j = 0; j < m_dwNumMaterials; j++)
//		{
//			if(m_pMeshTextures[j])
//			{
//				m_pMeshTextures[j]->Release();
//				m_pMeshTextures[j] = NULL;
//			}
//		}
//
//		delete[] m_pMeshTextures;
//	}
//
//	if(m_pMesh)
//	{
//		m_pMesh->Release();
//		m_pMesh = NULL;
//	}
//	/////////////////////////////////////////////////////////////////////////////
//}